<template>
  <Promised :promise="getTemplateAsync">
    <template v-slot:pending>
      <Skeleton
        :rows="8"
      />
    </template>
    <template v-slot="data">
      <section>
        <div class="template-container">
          <a-card>
            <Form :data="data" />
          </a-card>
        </div>
      </section>
    </template>
  </Promised>
</template>

<script>
import { getTemplate } from '@/api/flow/admin_message'
import Form from './Form/index.vue'
import props from './props'

export default {
  mixins: [props],

  components: {
    Form,
  },

  data () {
    return {
      getTemplateAsync: null,
    }
  },

  created () {
    this.getTemplateAsync = this.getTemplate()
  },

  methods: {
    // 获取模板
    getTemplate () {
      return new Promise((resolve, reject) => {
         getTemplate(this.id, this.mode)
          .then(data => {
            console.log(data, 'dadadad')
            resolve(data)
          })
          .catch(error => {
            reject(error)
          })
      })
    },
  },
}
</script>
